#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

int n, m;

int main()
{
    cin >> n >> m;
    int ret = n;
    for (int i = 0; i < m - 1; i++)
    {
        ret = (ret * (n - 1)) % 109;
    }
    cout << ret << endl;
    return 0;
}